package com.lxb;

public class MaxArea {
    public static void main(String[] args) {

        int n[] = {1,3,2,5,25,24,5};
        int p = 0;
        int l = n.length-1;
        int area = 0;
        for(int i=p;i<l;i++){
            if (i == 0) {
                int minH = Math.min(n[p],n[l]);
                int width = l - p;
                area = Math.max(minH * width,area);
            }else if (n[l] <= n[p]){
                l = l-1;
                int minH = Math.min(n[p],n[l]);
                int width = l - p;
                area = Math.max(minH * width,area);
            }else {
                p = p+1;
                int minH = Math.min(n[p],n[l]);
                int width = l - p;
                area = Math.max(minH * width,area);
            }

        }

        System.out.println(area);

    }
}
